package com.micro.commonlibrary.tools;

import java.util.regex.Pattern;

public class RegExrTools {
    private RegExrTools(){

    }
    public static boolean isPhone(String phone) {
        String regExr = "1[3,4,5,6,7,9,8]\\d{9}$";
        return Pattern.matches(regExr, phone);
    }

    public static boolean isEmail(String email) {
        String regExr = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
        return Pattern.matches(regExr, email);
    }

    public static boolean isIDCard(String IdCard) {
        String regExr = "(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)";
        return Pattern.matches(regExr, IdCard);
    }

    //    以字母开头，长度在6~18之间，只能包含字母、数字和下划线
    public static boolean isPass(String pass) {
        String regExr = "^[a-zA-Z]\\w{5,17}$";
        return Pattern.matches(regExr, pass);
    }


}
